export interface User {
  id: string;
  email: string;
  firstName?: string;
  lastName?: string;
  type: string;
  status: string;
  avatar?: string;
  tenantId?: string;
  roleId?: string;
  createdAt: string;
  updatedAt: string;
}

export interface Tenant {
  id: string;
  name: string;
  subdomain: string;
  planId: string;
  status: string;
  config?: any;
  trialEndsAt?: string;
  subscriptionEndsAt?: string;
  createdAt: string;
  updatedAt: string;
  // 关联数据（populate）
  plan?: Plan;
}

export interface Role {
  id: string;
  tenantId?: string;
  name: string;
  code?: string;
  description?: string;
  isSystem?: boolean;
  status: boolean;
  createdAt: string;
  updatedAt: string;
}

export interface Permission {
  id: string;
  resource: string;
  action: string;
  description?: string;
  module?: string;
  moduleName?: string;
  isSystem?: boolean;
  sortOrder?: number;
  createdAt: string;
  updatedAt: string;
}

export interface Menu {
  id: string;
  tenantId?: string;
  parentId?: string;
  name: string;
  title: string;
  english?: string;
  type: 'directory' | 'menu' | 'button';
  path?: string;
  component?: string;
  icon?: string;
  permission?: string;
  orderNum: number;
  visible: boolean;
  status: boolean;
  cache: boolean;
  redirect?: string;
  children?: Menu[];
  createdAt: string;
  updatedAt: string;
}

export interface AuditLog {
  id: string;
  tenantId?: string;
  userId: string;
  action: string;
  resource?: string;
  resourceId?: string;
  details?: any;
  ipAddress?: string;
  userAgent?: string;
  createdAt: string;
}

export interface Plan {
  id: string;
  name: string;
  code: string;
  description?: string;
  price: number;
  billingCycleCode: string;
  priceMonthly: number;
  priceYearly: number;
  maxUsers?: number;
  maxStorage?: number;
  maxProjects?: number;
  supportLevel: string;
  hasApiAccess: boolean;
  hasCustomDomain: boolean;
  hasWhiteLabel: boolean;
  hasSso: boolean;
  hasAdvancedAnalytics: boolean;
  isActive: boolean;
  sortOrder: number;
  createdAt: string;
  updatedAt: string;
}

export interface DictionaryType {
  id: string;
  tenantId?: string;
  code: string;
  name: string;
  english?: string;
  description?: string;
  status: boolean;
  itemCount?: number; // 字典项数量（后端子查询计算）
  createdAt: string;
  updatedAt: string;
}

export interface DictionaryItem {
  id: string;
  typeId: string;
  label: string;
  english?: string;
  value: string;
  orderNum: number;
  status: boolean;
  description?: string;
  createdAt: string;
  updatedAt: string;
}

export interface ApiResponse<T = any> {
  success: boolean;
  message: string;
  data: T;
  code?: number;
  errors?: Array<{ field: string; message: string }>;
  pagination?: {
    total: number;
    page: number;
    pageSize: number;
    totalPages: number;
  };
}

export interface PaginationParams {
  page: number;
  pageSize: number;
}

export interface PaginatedResponse<T = any> {
  data: T[];
  pagination: {
    total: number;
    page: number;
    pageSize: number;
    totalPages: number;
  };
}

export type FormMode = 'create' | 'edit' | 'view';
